/*
	Colored Trails
	
	Copyright (C) 2006, President and Fellows of Harvard College.  All Rights Reserved.
	
	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

package ctgui.original;

import edu.harvard.eecs.airg.coloredtrails.client.ui.ColoredTrailsBoardPanel;
import edu.harvard.eecs.airg.coloredtrails.client.ui.ColoredTrailsBoardWindow;


import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;

import javax.swing.*;
import java.awt.*;

/**
 * The BoardWindow in which the BoardPanel is displayed as well as all
 * allocated chips to players and phase status (e.g., the main game
 * window).
 *
 * @author Paul Heymann (ct3@heymann.be)
 */
public class BoardWindow extends JFrame implements ColoredTrailsBoardWindow {
    private BoardPanel bp = null;
    private AllPlayersChipDisplay apcd = new AllPlayersChipDisplay(GUI.getAgent().getGameStatus());
    private PhaseInfoDisplay pid = null;
    private JPanel encloserPanel;
    private JPanel playerChipsPanel;
    private JPanel mainPanel;
    private JPanel phasesPanel;

    public BoardWindow() {
        setTitle("Game Board - Name "+ GUI.getAgent().getClientName());
        setBackground(Color.WHITE);
        encloserPanel.setBackground(Color.WHITE);
        playerChipsPanel.setBackground(Color.WHITE);
        phasesPanel.setBackground(Color.WHITE);
        mainPanel.setBackground(Color.WHITE);
        bp = new BoardPanel();
        pid = new PhaseInfoDisplay();
        encloserPanel.add(bp);
        playerChipsPanel.add(apcd);
        phasesPanel.add(pid);
        setContentPane(mainPanel);
        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

        pack();
    }


    /* (non-Javadoc)
	 * @see ctgui.original.ColoredTrailsBoardWindow#getBoardPanel()
	 */
    public ColoredTrailsBoardPanel getBoardPanel() {
        return bp;
    }


    /* (non-Javadoc)
	 * @see ctgui.original.ColoredTrailsBoardWindow#getAllPlayersChipsDisplay()
	 */
    public AllPlayersChipDisplay getAllPlayersChipsDisplay() {
        return apcd;
    }


    /* (non-Javadoc)
	 * @see ctgui.original.ColoredTrailsBoardWindow#showBoardWindow()
	 */
    public void showBoardWindow() {
        setVisible(true);
    }

    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// !!! IMPORTANT !!!
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * !!! IMPORTANT !!!
     * DO NOT edit this method OR call it in your code!
     */
    private void $$$setupUI$$$() {
        mainPanel = new JPanel();
        mainPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0,
                0, 0), -1,
                -1));
        encloserPanel = new JPanel();
        mainPanel.add(encloserPanel,
                new GridConstraints(1, 0, 1, 1,
                        GridConstraints.ANCHOR_CENTER,
                        GridConstraints.FILL_BOTH,
                        GridConstraints.SIZEPOLICY_CAN_SHRINK |
                GridConstraints.SIZEPOLICY_CAN_GROW,
                        GridConstraints.SIZEPOLICY_FIXED, null,
                        new Dimension(-1, 280), null));
        encloserPanel.setBorder(BorderFactory.createTitledBorder(
                BorderFactory.createEtchedBorder(),
                "Board Display"));
        phasesPanel = new JPanel();
        mainPanel.add(phasesPanel,
                new GridConstraints(0, 0, 1, 1,
                        GridConstraints.ANCHOR_CENTER,
                        GridConstraints.FILL_BOTH,
                        GridConstraints.SIZEPOLICY_FIXED,
                        GridConstraints.SIZEPOLICY_FIXED, null,
                        new Dimension(-1, 150), null));
        phasesPanel.setBorder(BorderFactory.createTitledBorder(
                BorderFactory.createEtchedBorder(),
                "Phases Display"));
        playerChipsPanel = new JPanel();
        mainPanel.add(playerChipsPanel,
                new GridConstraints(2, 0, 1, 1,
                        GridConstraints.ANCHOR_CENTER,
                        GridConstraints.FILL_BOTH,
                        GridConstraints.SIZEPOLICY_CAN_SHRINK |
                GridConstraints.SIZEPOLICY_CAN_GROW,
                        GridConstraints.SIZEPOLICY_CAN_SHRINK |
                GridConstraints.SIZEPOLICY_CAN_GROW,
                        new Dimension(-1, 125), null, null));
        playerChipsPanel.setBorder(BorderFactory.createTitledBorder(
                BorderFactory.createEtchedBorder(),
                "Player Chips Display"));
    }
}
